home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.024.Teach / teach.c / uevent.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-24  |  3.2 KB  |  141 lines  |  [TEXT/MPS ]

  1. /**********************************************************************
  2. *
  3. * teach uevent.c -- Version 3.0
  4. *
  5. * Copyright (c)
  6. * Apple Computer, Inc.  1986-1990
  7. * All Rights Reserved.
  8. *
  9. * Developer Technical Support Apple II Sample Code
  10. *
  11. * This file contains the code which implements the
  12. * main event loop used by the Teach program.
  13. *
  14. **********************************************************************/
  15.  
  16. #include <types.h>
  17. #include <menu.h>
  18. #include <quickdraw.h>
  19. #include <window.h>
  20. #include "teach.h"
  21.  
  22. extern WmTaskRec        event;
  23. extern unsigned int     quitFlag;
  24. extern GrafPortPtr        lastWindow;
  25.  
  26. /**********************************************************************/
  27.  
  28. void    enableDAItems()
  29. {
  30.     EnableMItem(UndoItem);
  31.     EnableMItem(CloseItem);
  32.     SetMenuFlag(0xFF7F, EditMenuID);
  33. }
  34.  
  35. /**********************************************************************/
  36.  
  37. void    enableAppItems()
  38. {
  39.     EnableMItem(SelectAllItem);
  40.     EnableMItem(CloseItem);
  41.     EnableMItem(SaveItem);
  42.     EnableMItem(SaveAsItem);
  43.     EnableMItem(PageSetupItem);
  44.     EnableMItem(PrintItem);
  45.     SetMenuFlag(0xFF7F, SizeMenuID);        /* enable the size menu */
  46.     SetMenuFlag(0xFF7F, StyleMenuID);        /* enable the style menu */
  47.     SetMenuFlag(0xFF7F, FontMenuID);        /* enable the font menu */
  48.     SetMenuFlag(0xFF7F, EditMenuID);        /* enable the edit menu */
  49. }
  50.  
  51. /**********************************************************************/
  52.  
  53. void    disableDAItems()
  54. {
  55.     DisableMItem(UndoItem);
  56. }
  57.  
  58. /**********************************************************************/
  59.  
  60. void    disableAppItems()
  61. {
  62.     SetMenuFlag(0x0080, EditMenuID);        /* disable the edit menu */
  63.     SetMenuFlag(0x0080, FontMenuID);        /* disable the font menu */
  64.     SetMenuFlag(0x0080, StyleMenuID);        /* disable the style menu */
  65.     SetMenuFlag(0x0080, SizeMenuID);        /* disable the size menu */
  66.     DisableMItem(SaveItem);
  67.     DisableMItem(SaveAsItem);
  68.     DisableMItem(PageSetupItem);
  69.     DisableMItem(PrintItem);
  70.     DisableMItem(SelectAllItem);
  71. }
  72.  
  73.  
  74.  
  75. /*********************************************************************
  76. *
  77. * CheckFrontW
  78. *
  79. * This routine checks the front window to see if any changes need
  80. * to be made to the menu items.
  81. *
  82. * We do this so that the edit items are only active when a desk
  83. * accessory is active.
  84. *
  85. *********************************************************************/
  86. void    checkFrontW()
  87. {
  88.     GrafPortPtr     theWindow;
  89.  
  90.     theWindow = FrontWindow();
  91.  
  92.     if (theWindow == lastWindow) return;
  93.         /* If the LastWindow is this window, we are all set. */
  94.  
  95.     if (!theWindow) {            /* If no front window... */
  96.         disableDAItems();
  97.         disableAppItems();
  98.         DisableMItem(CloseItem);
  99.     }
  100.     else {                        /* Look at what kind of window we have... */
  101.         if (GetSysWFlag(theWindow)) {
  102.             disableAppItems();
  103.             enableDAItems();
  104.         }
  105.         else {
  106.             disableDAItems();
  107.             enableAppItems();
  108.         }
  109.     }
  110.  
  111.     DrawMenuBar();
  112.     lastWindow = theWindow;
  113. }
  114.  
  115.  
  116.  
  117. /*************************************************************************
  118. *
  119. * MainEvent
  120. *
  121. * This is the main part of the program.  The program cycles in this
  122. * loop until the user choose select.
  123. *
  124. *************************************************************************/
  125. void    mainEvent()
  126. {
  127.     for (;;) {
  128.         checkFrontW();
  129.         switch(TaskMaster(0xFFFF, &event)) {
  130.             case wInGoAway:
  131.                 doCloseTop();
  132.                 break;
  133.             case wInSpecial:
  134.             case wInMenuBar:
  135.                 doMenu();
  136.                 break;
  137.         }
  138.         if (quitFlag) break;
  139.     }
  140. }
  141.